#include<bits/stdc++.h>
using namespace std;
int d[20],v[1005],a[1005],p[1000005][2];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t,s1=0,s2=0;
    cin>>t;
    for(int i=1;i<=t;i++){
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i][0];
        }
        for(int i=1;i<=n;i++){
            int tf=0;
            for(int j=1;j<=m;j++){
                if((m*m-v[i]*v[i])/(2*a[i])+d[i]>p[j][0]){
                    if(tf==0){
                        s1+=1;
                        p[j][1]=1;
                        tf=1;
                    }
                }
            }
        }
        for(int i=1;i<=m;i++){
            if(p[i][1]!=1) s2+=1;
        }
        cout<<s1<<" "<<s2<<endl;
    }
    return 0;
}